home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / ams__l~1.zoo / man / fastcoun.man < prev    next >
Encoding:
Text File  |  1993-09-05  |  4.4 KB  |  141 lines

  1.                         ATARI MACHINE SPECIFIC LIBRARY
  2.  
  3.  
  4.  
  5. NAME
  6.      FastCounter - high speed incremental number display
  7.  
  8. SYNOPSIS
  9.      #include <FastCounter.h>
  10.  
  11.      class FastCounter
  12.      class CounterFont
  13.  
  14. DESCRIPTION
  15.      Many real-time games and similar applications require a rapidly
  16.      updated on-screen display for internal values such as score, or
  17.      other often-changing value.  This module provides very fast
  18.      decimal counters, in user-defined fonts.
  19.  
  20. CLASSES
  21.      A FastCounter is a screen-displayable object that can be added
  22.      to, subtracted from, or set to a specific value.  It can be
  23.      displayed with or without leading zeroes.  It should not become
  24.      negative.
  25.  
  26. CLASS MEMBERS
  27.   FastCounter::
  28.  
  29.      FastCounter(CounterFont*, int x, int y,
  30.                  unsigned v=0, short digits=6, short plane=0)
  31.        Use given font, draw at screen pixel position (x,y), on the
  32.        given bitplane, with initial counter value v, using the given
  33.        number of digits, with zero suppression turned on by default.
  34.  
  35.        Digits will be rounded up to a multiple of 2.
  36.        x will be rounded up to a multiple of 16.
  37.  
  38.        The bitplane draw on, and whas being drawn on determines the 
  39.        colour the counter will be drawn in.  (See examples)
  40.  
  41.      void Draw()
  42.        Draw on current page.  (See DoubleBuffer)
  43.  
  44.      void Add(short)
  45.      void operator ++ ()
  46.      void operator -- ()
  47.      void operator += (short x)
  48.      void operator -= (short x)
  49.        Increase/decrease.
  50.  
  51.      void Set(unsigned)
  52.        Set to a value.
  53.  
  54.      FastCounter& operator = (unsigned x)
  55.        Set to a value, return self.
  56.  
  57.      operator int()
  58.        Convert to int.
  59.  
  60.      operator double()
  61.        Convert to double.
  62.  
  63.      void MoveTo(short x,short y,short plane=0)
  64.        Reposition on screen.
  65.  
  66.      void ZeroSuppression(bool on=TRUE)
  67.        Enable/disable suppression of leading zeroes.
  68.        Turned on by default.
  69.  
  70.   CounterFont::
  71.  
  72.      CounterFont(short Height)
  73.        Create a font with digits on the given height.
  74.  
  75.      void GetImages(Screen&,short x,short y)
  76.        Get image for the digits from the given (x,y) location of the given
  77.        screen.  (x,y) should be the top-left corner of the digit '0', and
  78.        each digit should be 8-pixels wide, and side-by-side.  If zero
  79.        suppression is required, 8 pixels to the left of the '0' should
  80.        specify the image for blank (usually just blank pixels).
  81.        x must be multiple of 16.
  82.  
  83.      void Draw(short,long Offset)
  84.        Draw a value at an offset into the current page.
  85.        Usually only used by FastCounter.
  86.        For 0<=x<=99, draw "00" to "99";
  87.        For 99<x<110, draw " x-100";
  88.        For x==110, draw "  ".
  89.  
  90. USAGE
  91.      Create a screen with "  0123456789" depicted in all bitplanes
  92.      (eg. use colour 15 in 16-colour modes)
  93.  
  94.      Each character 8 pixels wide, and all the same height.
  95.  
  96.      Create a CounterFont from this screen.
  97.      Create FastCounters from this font.
  98.  
  99.      Different fonts may be used for different counters.
  100.  
  101.      Simply draw the counter at each iteration of the main animation
  102.      loop, since it draws incrementally (ie. only draws if it's value
  103.      changes, and then only those digits that changed).
  104.  
  105. EXAMPLES
  106.      If a colour 3 counter is required, the background would be either:
  107.        colour 1, and draw the counter on bitplane 1 (1+2**1=3)
  108.        colour 2, and draw the counter on bitplane 0 (2+2**0=3)
  109.        colour 7, with the images of the digits draw in inverse,
  110.                  and draw the counter on bitplane 2 (7-2**2=3)
  111.        colour 11, with the images of the digits draw in inverse,
  112.                  and draw the counter on bitplane 3 (11-2**3=3)
  113.  
  114.      Multi-coloured counters are possible - with a multicoloured
  115.      background.
  116.  
  117. SEE ALSO
  118.      DoubleBuffer, Screen
  119.  
  120. DIAGNOSTICS
  121.      No range checking is performed.
  122.  
  123. BUGS
  124.      Only an even number of digits are allowed.
  125.      Single-bitplane graphics can be confusing to the programmer.
  126.  
  127. AUTHOR
  128.      Warwick Allison, 1992.
  129.      warwick@cs.uq.oz.au
  130.  
  131. COPYING
  132.      This functionality is part of the Atari Machine Specific Library,
  133.      and is Copyright 1992 by Warwick W. Allison.
  134.  
  135.      The Atari Machine Specific Library is free and protected under the
  136.      GNU Library General Public License.
  137.  
  138.      You are free to copy and modify these sources, provided you acknowledge
  139.      the origin by retaining this notice, and adhere to the conditions
  140.      described in the GNU LGPL.
  141.